home *** CD-ROM | disk | FTP | other *** search
Text File | 2002-05-10 | 47.2 KB | 1,835 lines |
- // buttons.cnh
-
- // -------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------
- // Init func Predeclaration
- func Gui_Component NewButton(Menu_Material _pMaterial);
- func Gui_Component NewButton_Size(Menu_Material _pMaterial,f32x _sx,f32x _sy);
- func Gui_Component NewButton_Text(Menu_Material _pFont,szx _sxTxt,f32x _sx,f32x _sy);
- func Gui_Component NewButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt);
- func Gui_Component NewButton3D(Menu_Mesh _pMesh);
- func Gui_Component NewButton_FrameText(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft,Menu_Material _pFont,szx _sxTxt);
- func Gui_Component NewButton_FrameTextWithHelp(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt);
- func Gui_Component NewButtonDyn(Menu_Material _pMaterial);
-
- func Gui_Component NewCheckbox(Menu_Material _pMaterial);
- func Gui_Component NewCheckbox_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _szTxt);
- func i32x Checkbox_bIsChecked(Gui_Component _pCheckbox);
-
- func Gui_Component NewRadioButton(Menu_Material _pMaterial,i32x _iValue);
- func Gui_Component NewRadioButton_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _szTxt,i32x _iValue);
- func Gui_Component NewRadioButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue);
- func Gui_Component NewRadioButton_CenterTextExt(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue,i32x _iWidth,i32x _iHeight);
- func Gui_Component NewTextRadioButton(Menu_Material _pFont,szx _szTxt,i32x _iValue);
-
- // CM2 graphic chart implementation
- func Gui_Component NewCM2Button(szx _sxTxt);
-
- func Gui_Component NewCM2InRaceButton1(szx _sxTxt);
- func Gui_Component NewCM2InRaceButton2(szx _sxTxt);
- func Gui_Component NewCM2InRaceButton(szx _sxTxt, szx _sxTxt2, szx _szContextualCaption);
-
- func Gui_Component NewCM2BmpButton(Menu_Material _pMaterial, i32x _iIndex, i32x _iOffset, szx _szContextualCaption);
- // end of CM2 graphic chart
-
-
-
-
- // Needed for contextual help
- var Gui_Component g_cCurrentHelpComponent;
-
- // Standard buttons
- // Data class
- class Gui_dtCheckbox
- {
- var boolx bChecked;
- };
- class Gui_dtRadioButton
- {
- var i32x iValue;
- var boolx bChecked;
- };
- class Gui_dtRadioButtonComposite
- {
- var Gui_Component gcRadioButton;
- var Gui_Component gcCaption;
- };
- class Gui_dtFrameTextButton
- {
- var Gui_Component gcRightButton;
- var Gui_Component gcCenterButton;
- var Gui_Component gcLeftButton;
- var Gui_Component gcText;
- };
- class Gui_dtCM2InRaceButton
- {
- var Gui_Component gcRightButton;
- var Gui_Component gcCenterButton;
- var Gui_Component gcLeftButton;
- var Gui_Component gcText;
- var boolx bChecked;
- var szx szContextualCaption;
- };
- class Gui_dtCM2BmpButton
- {
- var i32x iIndex;
- var i32x iOffset;
- var boolx bChecked;
- var szx szContextualCaption;
- };
-
- // Message
- message ClickDown(Gui_Component _pComponent);
- message ClickUp(Gui_Component _pComponent);
- message Click(Gui_Component _pComponent);
- message RightClick(Gui_Component _pComponent);
- message MiddleClick(Gui_Component _pComponent);
- message RadioCheck(Gui_Component _pComponent,i32x _iValue);
- message Check(Gui_Component _pComponent);
- message QuietRadioCheck(i32x _iValue);
- message Uncheck(Gui_Component _pComponent);
- message QuietCheck();
- message QuietUncheck();
- message MouseClick(i32x _iX,i32x _iY,i32x _iButton);
- message MouseLeave(i32x _iX, i32x _iY);
-
- // -------------------------------------------------------------
- // -------------------------------------------------------------
-
-
- // Predeclaration
- func void ButtonComposite_OnClick(Gui_Component _pComponent);
- func i32x ButtonComposite_OnMouseEnter(i32x _iX,i32x _iY);
- func i32x ButtonComposite_OnMouseLeave(i32x _iX,i32x _iY);
- func i32x ButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
- func i32x ButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
- func i32x Button_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
-
- func void HelpButtonComposite_OnClick(Gui_Component _pComponent);
- func i32x HelpButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
- func i32x HelpButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
-
-
- func i32x ButtonDyn_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
- func i32x ButtonDyn_OnMouseEnter(i32x _iX,i32x _iY);
- func i32x ButtonDyn_OnMouseLeave(i32x _iX,i32x _iY);
- func i32x ButtonDyn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
- func i32x ButtonDyn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
-
- func i32x Checkbox_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
- func i32x Checkbox_OnQuietCheck();
- func i32x Checkbox_OnQuietUncheck();
- func i32x Checkbox_OnEnable();
- func i32x Checkbox_OnDisable();
-
- func i32x RadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
- func void RadioButton_OnQuietCheck(i32x _iValue);
- func i32x TextRadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
- func void TextRadioButton_OnQuietCheck(i32x _iValue);
- func void RadioButtonComposite_OnQuietCheck(i32x _iValue);
-
-
- func void CM2InRaceButton_OnClick(Gui_Component _pComponent);
- func i32x CM2InRaceButton_OnMouseEnter(i32x _iX,i32x _iY);
- func i32x CM2InRaceButton_OnMouseLeave(i32x _iX,i32x _iY);
- func i32x CM2InRaceButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
- func i32x CM2InRaceButton_OnUncheck(Gui_Component _pSender);
- func i32x CM2InRaceButton_OnCaption(szx _sxCaption);
-
-
- func void CM2BmpButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
- func i32x CM2BmpButton_OnMouseEnter(i32x _iX,i32x _iY);
- func i32x CM2BmpButton_OnMouseLeave(i32x _iX,i32x _iY);
- func i32x CM2BmpButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
- func i32x CM2BmpButton_OnUncheck(Gui_Component _pSender);
- func i32x CM2BmpButton_OnCheck(Gui_Component _pSender);
-
-
- // Message handling interface
- interface Gui_iBitmapButtonDyn
- {
- ButtonDyn_OnMouseClick MouseClick;
- ButtonDyn_OnMouseDown MouseDown;
- ButtonDyn_OnMouseEnter MouseEnter;
- ButtonDyn_OnMouseLeave MouseLeave;
- ButtonDyn_OnMouseUp MouseUp;
- }
- interface Gui_iBitmapButton
- {
- Button_OnMouseClick MouseClick;
- }
- interface Gui_iBitmapCheckbox
- {
- Checkbox_OnMouseClick MouseClick;
- Checkbox_OnQuietCheck QuietCheck;
- Checkbox_OnQuietUncheck QuietUncheck;
-
- Checkbox_OnEnable Enable;
- Checkbox_OnDisable Disable;
- }
- interface Gui_iBitmapRadioButton
- {
- RadioButton_OnMouseClick MouseClick;
-
- RadioButton_OnQuietCheck QuietRadioCheck;
- }
- interface Gui_iTextRadioButton
- {
- TextRadioButton_OnMouseClick MouseClick;
-
- TextRadioButton_OnQuietCheck QuietRadioCheck;
- }
-
- interface Gui_iButtonComposite
- {
- ButtonComposite_OnClick Click;
- ButtonComposite_OnMouseDown MouseDown;
- ButtonComposite_OnMouseEnter MouseEnter;
- ButtonComposite_OnMouseLeave MouseLeave;
- }
-
- interface Gui_iHelpButtonComposite
- {
- HelpButtonComposite_OnClick Click;
- HelpButtonComposite_OnMouseDown MouseDown;
- HelpButtonComposite_OnMouseUp MouseUp;
- }
-
- interface Gui_iCheckbox_Composite
- {
- }
-
- interface Gui_iRadioButton_Composite
- {
- RadioButtonComposite_OnQuietCheck QuietRadioCheck;
- }
-
- interface Gui_iCM2InRaceButton
- {
- CM2InRaceButton_OnClick Click;
- CM2InRaceButton_OnMouseDown MouseDown;
- CM2InRaceButton_OnMouseEnter MouseEnter;
- CM2InRaceButton_OnMouseLeave MouseLeave;
- CM2InRaceButton_OnUncheck Uncheck;
- CM2InRaceButton_OnCaption Caption;
- }
-
- interface Gui_iCM2BmpButton
- {
- CM2BmpButton_OnMouseClick MouseClick;
- CM2BmpButton_OnMouseDown MouseDown;
- CM2BmpButton_OnMouseEnter MouseEnter;
- CM2BmpButton_OnMouseLeave MouseLeave;
- CM2BmpButton_OnUncheck Uncheck;
- CM2BmpButton_OnCheck Check;
- }
-
-
-
- /*
- * Function : Button_Init button initializer
- * Parameters : _pMaterial material pointer
- */
- func Gui_Component NewButton(Menu_Material _pMaterial)
- {
- var Menu_Sprite sprite;
- var Gui_Component container;
- var f32x sx,sy;
- var i32x iArea;
-
- // Create container with button interface
- container = NewContainer(Gui_iBitmapButton);
- CatchEvent(container,e_GUI_Event_Mouse_Move);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pMaterial);
- iArea = e_GUI_State_Enabled;
- SetArea(sprite,iArea);
-
- // Get size of area of index e_GUI_State_Enabled
- sx = GetAreaWidth(_pMaterial,iArea);
- sy = GetAreaHeight(_pMaterial,iArea);
-
- // Strech container to area size
- StretchTo(container,sx,sy);
-
- // Define default align left/top (quicker than zoom)
- SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
-
- // Attach the sprite to this container
- AttachSprite(container,sprite);
-
- // Tell Gui to clip this sprite to container size
- Clip(container);
-
- return container;
- }
-
- /*
- * Function : NewButtonDyn button dyn initializer
- * Parameters : _pMaterial material pointer
- */
- func Gui_Component NewButtonDyn(Menu_Material _pMaterial)
- {
- var Menu_Sprite sprite;
- var Gui_Component container;
- var f32x sx,sy;
- var i32x iArea;
-
- // Create container with button interface
- container = NewContainer(Gui_iBitmapButtonDyn);
- CatchEvent(container,e_GUI_Event_Mouse_Move);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pMaterial);
- iArea = e_GUI_State_Enabled;
- SetArea(sprite,iArea);
-
- // Get size of area of index e_GUI_State_Enabled
- sx = GetAreaWidth(_pMaterial,iArea);
- sy = GetAreaHeight(_pMaterial,iArea);
-
- // Strech container to area size
- StretchTo(container,sx,sy);
-
- // Define default align left/top (quicker than zoom)
- SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
-
- // Attach the sprite to this container
- AttachSprite(container,sprite);
-
- // Tell Gui to clip this sprite to container size
- Clip(container);
-
- return container;
- }
-
- /*
- * Function : Button_Init button initializer
- * Parameters : _pMaterial material pointer
- */
- func Gui_Component NewButton3D(Menu_Mesh _pMesh)
- {
- var Menu_Sprite sprite;
- var Gui_Component container;
- var f32x sx,sy,s;
-
- // Compute resolution scale factor
- s = g_fScreenScaleFactor;
-
- // Create container with button interface
- container = NewContainer(Gui_iBitmapButton);
- SetScale(container,s);
-
- CatchEvent(container,e_GUI_Event_Mouse_Move);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite3D(_pMesh);
-
- // Get size of area of index e_GUI_State_Enabled
- sx = GetMeshWidth(_pMesh) * s;
- sy = GetMeshHeight(_pMesh) * s;
-
- // Strech container to area size
- StretchTo(container,sx,sy);
-
- // Define default align left/top (quicker than zoom)
- SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
-
- // Attach the sprite to this container
- AttachSprite(container,sprite);
-
- return container;
- }
-
- func Gui_Component NewCheckbox(Menu_Material _pMaterial)
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component container;
-
- // Create container with button interface
- container = NewButton(_pMaterial);
-
- // Affect data pointer
- pdtCheckbox = new Gui_dtCheckbox;
- pdtCheckbox.bChecked = false;
- SetData(container,pdtCheckbox);
-
- // Change interface to checkbox interface
- SetInterface(container,Gui_iBitmapCheckbox);
-
- //mao debug for now
- SetShadingMode(GetSprite(container),DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
- SetColor(container,MakeARGB(255,255,255,255));
-
- return container;
- }
-
- /*
- * Function : Checkbox button initializer with text param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- */
- func Gui_Component NewCheckbox_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption,container,composite;
- var i32x iArea;
- var i32x wc,w,h;
-
- // Create an object that will contain Bitmap buton + caption
- composite = NewObject(Gui_iCheckbox_Composite);
- Transparent(composite);
-
- // Two component in composite button
- SetComponentNumber(composite,2);
-
- // Create a caption that fit button
- caption = NewCaption(_pFont,_sxTxt);
- SetColor(caption,4278255360);
- wc = SizeX(caption);
- // Vertical Center text in caption
- SetAlign(caption,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
-
- // Disable caption
- caption<<Disable();
-
- // Create A bitmap checkbox
- container = NewCheckbox(_pMaterial);
- // Get button size
- w = SizeX(container);
- h = SizeY(container);
- // Stretch button to overwrite cation
- Stretch(container,wc,0);
-
- // Move caption
- Move(caption,w,0);
- // Stretch caption to button height
- StretchTo(caption,wc,h);
-
- // Mount containers into object
- MountComponent(composite,caption);
- MountComponent(composite,container);
-
- // Stretch composite to fit content
- StretchTo(composite,w+wc,h);
-
- return composite;
- }
-
- /*
- * Function : RadioButton button initializer with text param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- */
- func Gui_Component NewRadioButton_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption,container,composite;
- var Gui_dtRadioButtonComposite pdtData;
- var i32x iArea;
- var i32x wc,w,h;
-
- // Create an object that will contain Bitmap buton + caption
- composite = NewObject(Gui_iRadioButton_Composite);
- Transparent(composite);
-
- pdtData = new Gui_dtRadioButtonComposite;
-
- // Affect data to composite
- SetData(composite,pdtData);
-
- // Two component in composite button
- SetComponentNumber(composite,2);
-
- // Create a caption that fit button
- caption = NewCaption(_pFont,_sxTxt);
- Clip(caption);
- wc = SizeX(caption);
- // Vertical Center text in caption
- SetAlign(caption,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
-
- // Disable caption
- caption<<Disable();
-
- // Create A bitmap checkbox
- container = NewRadioButton(_pMaterial,_iValue);
- // Get button size
- w = SizeX(container);
- h = SizeY(container);
- // Stretch button to overwrite cation
- Stretch(container,wc,0);
-
- // Move caption
- Move(caption,w,0);
- // Stretch caption to button height
- StretchTo(caption,wc,h);
-
- // Mount containers into object
- MountComponent(composite,caption);
- MountComponent(composite,container);
- pdtData.gcCaption = caption;
- pdtData.gcRadioButton = container;
-
- // Stretch composite to fit content
- StretchTo(composite,w+wc,h);
-
- return composite;
- }
-
-
-
- /*
- * Function : RadioButton button initializer with text param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- */
- func Gui_Component NewRadioButton_CenterTextExt(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue,i32x _iWidth,i32x _iHeight)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption,container,composite;
- var Gui_dtRadioButtonComposite pdtData;
- var i32x iArea;
- var i32x w,h;
-
- // Create an object that will contain Bitmap buton + caption over the
- composite = NewObject(Gui_iRadioButton_Composite);
- Transparent(composite);
-
- pdtData = new Gui_dtRadioButtonComposite;
-
- // Affect data to composite
- SetData(composite,pdtData);
-
- // Two component in composite button
- SetComponentNumber(composite,2);
-
- // Create a caption that fit button
- caption = NewCaption(_pFont,_sxTxt);
- if(_iWidth==0)
- w = SizeX(caption);
- else
- w = _iWidth;
-
- if(_iHeight==0)
- h = SizeY(caption);
- else
- h = _iHeight;
-
- // Vertical Center text in caption
- SetAlign(caption,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Disable caption
- caption<<Disable();
-
- // Create A bitmap checkbox
- container = NewRadioButton(_pMaterial,_iValue);
- SetAlign(container,e_GUI_HAlign_Zoom,e_GUI_VAlign_Zoom);
- StretchTo(container,w,h);
-
- // Mount containers into object
- MountComponent(composite,container);
- MountComponent(composite,caption);
-
- pdtData.gcCaption = caption;
- pdtData.gcRadioButton = container;
-
- // Stretch composite to fit content
- StretchTo(composite,w,h);
-
- return composite;
- }
-
-
- func Gui_Component NewRadioButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue)
- {
- return NewRadioButton_CenterTextExt(_pMaterial,_pFont,_sxTxt,_iValue,0,0);
- }
-
-
- func Gui_Component NewRadioButton(Menu_Material _pMaterial,i32x _iValue)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component container;
-
- // Create container with button interface
- container = NewCheckbox(_pMaterial);
-
- // Affect data pointer
- pdtRadio = new Gui_dtRadioButton;
- pdtRadio.bChecked = false;
- pdtRadio.iValue = _iValue;
-
-
- // Change interface to checkbox interface
- AddInterface(container,Gui_iBitmapRadioButton,pdtRadio);
-
- return container;
- }
-
- /*
- * Function : Button_Init button initializer
- * Parameters : _pMaterial material pointer
- */
- func Gui_Component NewButton_Text(Menu_Material _pFont,szx _sxTxt,f32x _sx,f32x _sy)
- {
- var Menu_Sprite sprite;
- var Gui_Component container;
- var f32x sx,sy;
- var i32x iArea;
-
- // Create container with button interface
- container = NewContainer(Gui_iBitmapButton);
- CatchEvent(container,e_GUI_Event_Mouse_Move);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pFont);
- SetText(sprite,_sxTxt);
-
- // Strech container to area size
- StretchTo(container,_sx,_sy);
-
- // Define default align left/top (quicker than zoom)
- SetAlign(container,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Attach the sprite to this container
- AttachSprite(container,sprite);
-
- // Tell Gui to clip this sprite to container size
- Clip(container);
-
- return container;
- }
-
- /*
- * Function : Button_Init button initializer with size param
- * Parameters : _pMaterial material pointer
- * Parameters : _sx,_sy wanted container size in pixel
- * Remarks : sprite will be zoomed to fit container don't need to clip
- */
- func Gui_Component NewButton_Size(Menu_Material _pMaterial,f32x _sx, f32x _sy)
- {
- var Menu_Sprite sprite;
- var Gui_Component component;
- var i32x iArea;
-
- // Create container with button interface
- component = NewContainer(Gui_iBitmapButton);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pMaterial);
- iArea = e_GUI_State_Enabled;
- SetArea(sprite,iArea);
-
- // Strech container to wanted size
- StretchTo(component,_sx,_sy);
-
- // Zoom sprite to fit container
- SetAlign(component,e_GUI_HAlign_Zoom,e_GUI_VAlign_Zoom);
-
- // Attach the sprite to this container
- AttachSprite(component,sprite);
-
- return component;
- }
-
- /*
- * Function : Button_Init button initializer with size param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- */
- func Gui_Component NewButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption,container,composite;
- var i32x iArea;
- var i32x w,h;
-
- // Create an object that will contain Bitmap buton + caption
- composite = NewObject(Gui_iButtonComposite);
-
- // Two component in composite button
- SetComponentNumber(composite,2);
-
- // Create A bitmap Button
- container = NewButton(_pMaterial);
- // Get button size
- w = SizeX(container);
- h = SizeY(container);
-
- // Create a caption that fit button
- caption = NewCaption(_pFont,_sxTxt);
- StretchTo(caption,w,h);
- // Center text in caption
- SetAlign(caption,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Disable caption
- caption<<Disable();
-
- // Mount containers into object
- MountComponent(composite,container);
- MountComponent(composite,caption);
-
- // Stretch composite to fit button
- StretchTo(composite,w,h);
-
- return composite;
- }
-
- /*
- * Function : Button_Init button initializer with size param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- */
- func Gui_Component NewButton_FrameText(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
- var Gui_dtFrameTextButton pdtData;
- var i32x iArea;
- var i32x w_button,h_button,w_text, w;
-
- // Create an object that will contain Bitmap buton + gcText
- composite = NewObject(Gui_iButtonComposite);
-
- // Two component in composite button
- SetComponentNumber(composite,3);
-
- // Create a gcText that fit button
- gcText = NewCaption(_pFont,_sxTxt);
- w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
- // Center text in gcText
- SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Disable text
- gcText<<Disable();
-
- // Create A bitmap Button (right button)
- gcRightButton = NewButton(_pMaterialRight);
- // Get button size
- w_button = SizeX(gcRightButton);
- h_button = SizeY(gcRightButton);
- // align button
- SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
-
- // create a bitmap button (center button)
- gcCenterButton = NewButton(_pMaterialCenter);
- SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
-
- // Create A bitmap Button (left button)
- gcLeftButton = NewButton(_pMaterialLeft);
- // align button
- SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
-
- // Stretch button and text
- w = w_text+w_button*2;
- StretchTo(gcText,w,h_button);
- StretchTo(gcRightButton,w,h_button);
- StretchTo(gcCenterButton, w-2*w_button, h_button);
- StretchTo(gcLeftButton, w, h_button);
- MoveTo(gcCenterButton, w_button, 0);
-
- // Set Data
- pdtData = new Gui_dtFrameTextButton;
- SetData(composite,pdtData);
- pdtData.gcRightButton = gcRightButton;
- pdtData.gcCenterButton = gcCenterButton;
- pdtData.gcLeftButton = gcLeftButton;
- pdtData.gcText = gcText;
-
- // Mount containers into object
- MountComponent(composite,gcRightButton);
- MountComponent(composite,gcCenterButton);
- MountComponent(composite,gcLeftButton);
- MountComponent(composite,gcText);
-
-
- // Stretch composite to fit button
- StretchTo(composite,w,h_button);
-
- return composite;
- }
-
-
- /*
- * Function : init a standard button according to CM2 graphic chart
- * Parameters : _sxTxt -> button caption
- */
- func Gui_Component NewCM2Button(szx _sxTxt)
- {
- return NewButton_FrameText(smBtnBlueRight, smBtnBlueCenter, smBtnBlueLeft, smBauer, _sxTxt);
- }
-
- func Gui_Component NewCM2InRaceButton2(szx _sxTxt)
- {
- return NewButton_FrameText(smBtnIGGrey2Right, smBtnIGGrey2Center, smBtnIGGrey2Left, smTrebuchet, _sxTxt);
- }
-
- /*
- * Function : NewCM2InRaceButton button initializer
- * Parameters : _sxTxt -> button caption; _sxTxt2 -> the other button caption to be compare with
- * _sxContextualHelp -> contextual caption
- */
- func Gui_Component NewCM2InRaceButton(szx _sxTxt, szx _sxTxt2, szx _szContextualCaption)
- {
- var Menu_Sprite sprite;
- var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
- var Gui_dtCM2InRaceButton pdtData;
- var i32x iArea;
- var i32x w_button,h_button,w_text,w_text2, w;
-
- // Create an object that will contain Bitmap buton + gcText
- composite = NewObject(Gui_iCM2InRaceButton);
-
- // Two component in composite button
- SetComponentNumber(composite,3);
-
- // Create a gcText that fit button
- gcText = NewCaption(smTrebuchet,_sxTxt);
- w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
- w_text2 = PrecalcTextWidth(GetSprite(gcText),_sxTxt2);
- if(w_text2>w_text)
- w_text=w_text2;
-
- // Center text in gcText
- SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Disable text
- gcText<<Disable();
-
- // Create A bitmap Button (right button)
- gcRightButton = NewButton(smBtnIGGrey2Right);
- // Get button size
- w_button = SizeX(gcRightButton);
- h_button = SizeY(gcRightButton);
- // align button
- SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
-
- // create a bitmap button (center button)
- gcCenterButton = NewButton(smBtnIGGrey2Center);
- SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
-
- // Create A bitmap Button (left button)
- gcLeftButton = NewButton(smBtnIGGrey2Left);
- // align button
- SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
-
- // Stretch button and text
- w = w_text+w_button*2;
- StretchTo(gcText,w,h_button);
- StretchTo(gcRightButton,w,h_button);
- StretchTo(gcCenterButton, w-2*w_button, h_button);
- StretchTo(gcLeftButton, w, h_button);
- MoveTo(gcCenterButton, w_button, 0);
-
- // Set Data
- pdtData = new Gui_dtCM2InRaceButton;
- SetData(composite,pdtData);
- pdtData.gcRightButton = gcRightButton;
- pdtData.gcCenterButton = gcCenterButton;
- pdtData.gcLeftButton = gcLeftButton;
- pdtData.gcText = gcText;
- pdtData.bChecked = 0;
- pdtData.szContextualCaption = _szContextualCaption;
-
- // Mount containers into object
- MountComponent(composite,gcRightButton);
- MountComponent(composite,gcCenterButton);
- MountComponent(composite,gcLeftButton);
- MountComponent(composite,gcText);
-
-
- // Stretch composite to fit button
- StretchTo(composite,w,h_button);
-
- return composite;
- }
-
-
-
- /*
- * Function : Composite Button click callback
- * Remarks : Simply transfer message to parent
- * Message : "Click"
- */
- func void HelpButtonComposite_OnClick(Gui_Component _pClicked)
- {
- var Gui_Component parent,pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
- parent = GetParent(pthis);
-
- /*
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),1);
- SetArea(GetSprite(pdtData.gcCenterButton),1);
- SetArea(GetSprite(pdtData.gcLeftButton),1);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
-
- // send mesg to parent
- */
- parent<<Click(pthis);
- }
-
- /*
- * Function : Composite Button on mouse down callback
- */
- func i32x HelpButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),2);
- SetArea(GetSprite(pdtData.gcCenterButton),2);
- SetArea(GetSprite(pdtData.gcLeftButton),2);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
-
- func i32x HelpButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_dtFrameTextButton pdtData;
-
- // println("HelpButtonComposite_OnMouseUp");
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
- }
-
-
-
- /*
- * Function : Button_Init button initializer with size param
- * Parameters : _pMaterial material pointer
- * Parameters : _pFont material pointer
- * Parameters : __sxTxt text
- * Works with help hint !!!
- */
- func Gui_Component NewButton_FrameTextWithHelp(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
- var Gui_dtFrameTextButton pdtData;
- var i32x iArea;
- var i32x w_button,h_button,w_text, w;
-
- // Create an object that will contain Bitmap buton + gcText
- composite = NewObject(Gui_iHelpButtonComposite);
-
- // Two component in composite button
- SetComponentNumber(composite,3);
-
- // Create a gcText that fit button
- gcText = NewCaption(_pFont,_sxTxt);
- w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
- // Center text in gcText
- SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
-
- // Disable text
- gcText<<Disable();
-
- // Create A bitmap Button (right button)
- gcRightButton = NewButton(_pMaterialRight);
- // Get button size
- w_button = SizeX(gcRightButton);
- h_button = SizeY(gcRightButton);
- // align button
- SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
-
- // create a bitmap button (center button)
- gcCenterButton = NewButton(_pMaterialCenter);
- SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
-
- // Create A bitmap Button (left button)
- gcLeftButton = NewButton(_pMaterialLeft);
- // align button
- SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
-
- // Stretch button and text
- w = w_text+w_button*2;
- StretchTo(gcText,w,h_button);
- StretchTo(gcRightButton,w,h_button);
- StretchTo(gcCenterButton, w-2*w_button, h_button);
- StretchTo(gcLeftButton, w, h_button);
- MoveTo(gcCenterButton, w_button, 0);
-
- // Set Data
- pdtData = new Gui_dtFrameTextButton;
- SetData(composite,pdtData);
- pdtData.gcRightButton = gcRightButton;
- pdtData.gcCenterButton = gcCenterButton;
- pdtData.gcLeftButton = gcLeftButton;
- pdtData.gcText = gcText;
-
- // Mount containers into object
- MountComponent(composite,gcRightButton);
- MountComponent(composite,gcCenterButton);
- MountComponent(composite,gcLeftButton);
- MountComponent(composite,gcText);
-
-
- // Stretch composite to fit button
- StretchTo(composite,w,h_button);
-
- return composite;
- }
-
-
- func Gui_Component NewCM2InRaceButton1(szx _sxTxt)
- {
- return NewButton_FrameTextWithHelp(smBtnIGGrey1Right, smBtnIGGrey1Center, smBtnIGGrey1Left, smTrebuchet, _sxTxt);
- }
-
-
-
- /*
- * Function : NewCM2BmpButton button initializer (bitmap button which handle the mouse message)
- * Parameters : _pMaterial material pointer; _iIndex sprite index; _iOffset number of different bitmaps (usually just one)
- */
- func Gui_Component NewCM2BmpButton(Menu_Material _pMaterial, i32x _iIndex, i32x _iOffset, szx _szContextualCaption)
- {
- var Menu_Sprite sprite;
- var Gui_Component container;
- var Gui_dtCM2BmpButton pdtCM2BmpButton;
- var f32x sx,sy;
- var i32x iArea;
-
- // Create container with button interface
- container = NewContainer(Gui_iCM2BmpButton);
- CatchEvent(container,e_GUI_Event_Mouse_Move);
-
- // Affect data pointer
- pdtCM2BmpButton = new Gui_dtCM2BmpButton;
- pdtCM2BmpButton.bChecked = false;
- pdtCM2BmpButton.iIndex = _iIndex;
- pdtCM2BmpButton.iOffset = _iOffset;
- pdtCM2BmpButton.szContextualCaption = _szContextualCaption;
- SetData(container,pdtCM2BmpButton);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pMaterial);
- iArea = e_GUI_State_Enabled;
- SetArea(sprite,iArea);
-
- // Get size of area of index e_GUI_State_Enabled
- sx = GetAreaWidth(_pMaterial,iArea);
- sy = GetAreaHeight(_pMaterial,iArea);
-
- // Strech container to area size
- StretchTo(container,sx,sy);
-
- // Define default align left/top (quicker than zoom)
- SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
-
- // Attach the sprite to this container
- AttachSprite(container,sprite);
-
- // Tell Gui to clip this sprite to container size
- Clip(container);
-
- return container;
- }
-
-
-
- /*
- * Function : Button Mouse click callback
- * Remarks : Test left click
- * Remarks : Push click message to parent
- * Message : "MouseClick"
- */
- func i32x Button_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
-
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<Click(pthis);
- }
- else if(_iButton == e_Gui_Mouse_Right_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<RightClick(pthis);
- }
- else if(_iButton == e_Gui_Mouse_Middle_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<MiddleClick(pthis);
- }
- return 0;
- }
-
- func i32x Checkbox_bIsChecked(Gui_Component _pCheckbox)
- {
- var Gui_dtCheckbox pdtCheckbox;
- pdtCheckbox = GetData(_pCheckbox);
- return (pdtCheckbox.bChecked==true);
- }
-
- func i32x Checkbox_OnQuietCheck()
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtCheckbox = GetData(pthis);
-
- if(pdtCheckbox.bChecked==false)
- {
- pdtCheckbox.bChecked = true;
-
- SetArea(GetSprite(pthis),1);
- SetArea(GetSprite(pthis),1);
- }
- return 1;
- }
-
- func i32x Checkbox_OnQuietUncheck()
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtCheckbox = GetData(pthis);
-
- if(pdtCheckbox.bChecked==true)
- {
- pdtCheckbox.bChecked = false;
-
- SetArea(GetSprite(pthis),0);
- SetArea(GetSprite(pthis),0);
- }
- return 1;
- }
-
- func i32x Checkbox_OnEnable()
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtCheckbox = GetData(pthis);
- if(pdtCheckbox.bChecked==false)
- {
- SetArea(GetSprite(pthis),0);
- SetArea(GetSprite(pthis),0);
- }
- else
- {
- SetArea(GetSprite(pthis),1);
- SetArea(GetSprite(pthis),1);
- }
- }
- func i32x Checkbox_OnDisable()
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtCheckbox = GetData(pthis);
- //SetArea(GetSprite(pthis),3);
- //SetArea(GetSprite(pthis),3);
- }
-
- func void RadioButton_OnQuietCheck(i32x _iValue)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtRadio = GetData(pthis);
-
- if(pdtRadio.iValue == _iValue)
- {
- pdtRadio.bChecked = true;
- SetArea(GetSprite(pthis),1);
- SetArea(GetSprite(pthis),1);
- }
- else
- {
- pdtRadio.bChecked = false;
- SetArea(GetSprite(pthis),0);
- SetArea(GetSprite(pthis),0);
- }
- }
-
- func void RadioButtonComposite_OnQuietCheck(i32x _iValue)
- {
- var Gui_dtRadioButtonComposite pdtData;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- pdtData.gcRadioButton<<QuietRadioCheck(_iValue);
- }
-
- /*
- * Function : Checkbox Mouse click callback
- * Remarks : Test left click
- * Remarks : Check or uncheck checkbox
- * Message : "MouseClick"
- */
- func i32x Checkbox_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_dtCheckbox pdtCheckbox;
- var Gui_Component pthis;
- var Gui_Component parent;
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
-
- pdtCheckbox = GetData(pthis);
- if(pdtCheckbox.bChecked==false)
- {
- Checkbox_OnQuietCheck();
- parent<<Click(pthis);
- parent<<Check(pthis);
- }
- else
- {
- Checkbox_OnQuietUncheck();
- parent<<Click(pthis);
- parent<<Uncheck(pthis);
- }
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Right_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<RightClick(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Middle_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<MiddleClick(pthis);
- return 1;
- }
- return 0;
- }
-
- /*
- * Function : Radio button Mouse click callback
- * Remarks : Test left click
- * Remarks : Check or uncheck checkbox
- * Message : "MouseClick"
- */
- func i32x RadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component pthis;
- var Gui_Component parent;
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
-
- pdtRadio = GetData(pthis);
- if(pdtRadio.bChecked==false)
- {
- RadioButton_OnQuietCheck(pdtRadio.iValue);
- parent<<RadioCheck(pthis,pdtRadio.iValue);
- }
- parent<<Click(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Right_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<RightClick(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Middle_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<MiddleClick(pthis);
- return 1;
- }
- return 0;
- }
-
- /*
- * Function : Composite Button click callback
- * Remarks : Simply transfer message to parent
- * Message : "Click"
- */
- func void ButtonComposite_OnClick(Gui_Component _pClicked)
- {
- var Gui_Component parent,pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
- parent = GetParent(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),1);
- SetArea(GetSprite(pdtData.gcCenterButton),1);
- SetArea(GetSprite(pdtData.gcLeftButton),1);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
-
- // send mesg to parent
- parent<<Click(pthis);
- }
-
- /*
- * Function : Composite Button enter callback
- */
- func i32x ButtonComposite_OnMouseEnter(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
-
- /*
- * Function : Composite Button leave callback
- */
- func i32x ButtonComposite_OnMouseLeave(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
- }
-
- /*
- * Function : Composite Button on mouse down callback
- */
- func i32x ButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_dtFrameTextButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- SetArea(GetSprite(pdtData.gcRightButton),2);
- SetArea(GetSprite(pdtData.gcCenterButton),2);
- SetArea(GetSprite(pdtData.gcLeftButton),2);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
-
- /*
- * Function : Button enter callback
- */
- func i32x ButtonDyn_OnMouseEnter(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
-
- pthis = GetThis();
-
- // change button style
- SetArea(GetSprite(pthis),1);
- }
-
- /*
- * Function : Button leave callback
- */
- func i32x ButtonDyn_OnMouseLeave(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
-
- pthis = GetThis();
-
- // change button style
- SetArea(GetSprite(pthis),0);
- }
-
- /*
- * Function : Button on mouse down callback
- */
- func i32x ButtonDyn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
-
- pthis = GetThis();
- parent = GetParent(pthis);
-
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- // change button style
- SetArea(GetSprite(pthis),2);
- // send mesg to parent
- parent<<ClickDown(pthis);
- }
- }
-
- /*
- * Function : Button on mouse up callback
- */
- func i32x ButtonDyn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
-
- pthis = GetThis();
- parent = GetParent(pthis);
-
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- // send mesg to parent
- parent<<ClickUp(pthis);
- }
- }
-
- /*
- * Function : Button Mouse click callback
- * Remarks : Test left click
- * Remarks : Push click message to parent
- * Message : "MouseClick"
- */
- func i32x ButtonDyn_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
-
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- pthis = GetThis();
-
- // change button style
- SetArea(GetSprite(pthis),3);
-
- parent = GetParent(pthis);
- parent<<Click(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Right_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<RightClick(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Middle_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<MiddleClick(pthis);
- return 1;
- }
- return 0;
- }
-
- func i32x TextRadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component pthis;
- var Gui_Component parent;
- if(_iButton == e_Gui_Mouse_Left_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
-
- pdtRadio = GetData(pthis);
- if(pdtRadio.bChecked==false)
- {
- TextRadioButton_OnQuietCheck(pdtRadio.iValue);
- parent<<RadioCheck(pthis,pdtRadio.iValue);
- }
- parent<<Click(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Right_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<RightClick(pthis);
- return 1;
- }
- else if(_iButton == e_Gui_Mouse_Middle_Button)
- {
- pthis = GetThis();
- parent = GetParent(pthis);
- parent<<MiddleClick(pthis);
- return 1;
- }
- return 0;
- }
- func void TextRadioButton_OnQuietCheck(i32x _iValue)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component pthis;
-
- pthis = GetThis();
- pdtRadio = GetData(pthis);
-
- if(pdtRadio.iValue == _iValue)
- {
- pdtRadio.bChecked = true;
- SetColor(pthis,cEBColor);
- }
- else
- {
- pdtRadio.bChecked = false;
- SetColor(pthis,cWhite);
- }
- }
-
- func Gui_Component NewTextRadioButton(Menu_Material _pFont,szx _szTxt,i32x _iValue)
- {
- var Gui_dtRadioButton pdtRadio;
- var Gui_Component container;
-
- // Create container with button interface
- container = NewCaption(_pFont,_szTxt);
- SetShadingMode(GetSprite(container),DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
-
- // Affect data pointer
- pdtRadio = new Gui_dtRadioButton;
- pdtRadio.bChecked = false;
- pdtRadio.iValue = _iValue;
-
- // Change interface to radio button interface
- SetInterface(container,Gui_iTextRadioButton);
- SetData(container,pdtRadio);
-
- return container;
- }
-
- /*
- * Function : CM2 In Race Button click callback
- * Remarks : Simply transfer message to parent
- * Message : "Click"
- */
- func void CM2InRaceButton_OnClick(Gui_Component _pClicked)
- {
- var Gui_Component parent,pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
- parent = GetParent(pthis);
-
- // change button style
- if(pdtData.bChecked)
- {
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- pdtData.bChecked=0;
-
- parent<<Uncheck(pthis);
- }
- else
- {
- SetArea(GetSprite(pdtData.gcRightButton),2);
- SetArea(GetSprite(pdtData.gcCenterButton),2);
- SetArea(GetSprite(pdtData.gcLeftButton),2);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- pdtData.bChecked=1;
-
- parent<<Click(pthis);
- }
- }
-
- /*
- * Function : Composite Button enter callback
- */
- func i32x CM2InRaceButton_OnMouseEnter(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- if(!pdtData.bChecked)
- {
- SetArea(GetSprite(pdtData.gcRightButton),1);
- SetArea(GetSprite(pdtData.gcCenterButton),1);
- SetArea(GetSprite(pdtData.gcLeftButton),1);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
-
- //Contextual Help
- if(strlen(pdtData.szContextualCaption)>=1)
- {
- g_gcManager<<MoveHint(_iX,_iY);
- g_gcManager<<ShowHint(pdtData.szContextualCaption);
- g_cCurrentHelpComponent=GetThis();
- }
- return 1;
- }
-
- /*
- * Function : Composite Button leave callback
- */
- func i32x CM2InRaceButton_OnMouseLeave(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- if(!pdtData.bChecked)
- {
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
- }
-
- //Contextual Help
- if(strlen(pdtData.szContextualCaption)>=1)
- {
- if(g_cCurrentHelpComponent==GetThis())
- {
- g_gcManager<<HideHint();
- g_cCurrentHelpComponent=NULL;
- }
- }
- return 1;
- }
-
- /*
- * Function : Button leave callback
- */
- func i32x CM2InRaceButton_OnUncheck(Gui_Component _pSender)
- {
- var Gui_Component pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- pdtData.bChecked=0;
- pthis<<MouseLeave(0,0);
- }
-
- /*
- * Function : Button caption
- */
- func i32x CM2InRaceButton_OnCaption(szx _sxCaption)
- {
- var Gui_Component pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button caption
- pdtData.gcText<<Caption(_sxCaption);
- }
-
- /*
- * Function : Composite Button on mouse down callback
- */
- func i32x CM2InRaceButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_dtCM2InRaceButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- if(!pdtData.bChecked)
- {
- SetArea(GetSprite(pdtData.gcRightButton),2);
- SetArea(GetSprite(pdtData.gcCenterButton),2);
- SetArea(GetSprite(pdtData.gcLeftButton),2);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
- else
- {
- SetArea(GetSprite(pdtData.gcRightButton),0);
- SetArea(GetSprite(pdtData.gcCenterButton),0);
- SetArea(GetSprite(pdtData.gcLeftButton),0);
- SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
- }
- }
-
- /*
- * Function : Button enter callback
- */
- func i32x CM2BmpButton_OnMouseEnter(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtCM2BmpButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- if(!pdtData.bChecked)
- SetArea(GetSprite(pthis),pdtData.iIndex+pdtData.iOffset);
-
- //Contextual Help
- if(strlen(pdtData.szContextualCaption)>=1)
- {
- g_gcManager<<MoveHint(_iX,_iY);
- g_gcManager<<ShowHint(pdtData.szContextualCaption);
- g_cCurrentHelpComponent=GetThis();
- }
- return 1;
- }
-
- /*
- * Function : Button leave callback
- */
- func i32x CM2BmpButton_OnMouseLeave(i32x _iX,i32x _iY)
- {
- var Gui_Component pthis;
- var Gui_dtCM2BmpButton pdtData;
-
- pthis = GetThis();
- pdtData = GetData(pthis);
-
- // change button style
- if(!pdtData.bChecked)
- SetArea(GetSprite(pthis),pdtData.iIndex);
-
- //Contextual Help
- if(strlen(pdtData.szContextualCaption)>=1)
- {
- if(g_cCurrentHelpComponent==GetThis())
- {
- g_gcManager<<HideHint();
- g_cCurrentHelpComponent=NULL;
- }
- }
- return 1;
- }
-
- /*
- * Function : Button leave callback
- */
- func i32x CM2BmpButton_OnUncheck(Gui_Component _pSender)
- {
- var Gui_Component pthis;
- var Gui_dtCM2BmpButton pdtButton;
-
- pthis = GetThis();
- pdtButton = GetData(pthis);
-
- // change button style
- pdtButton.bChecked=0;
- pthis<<MouseLeave(0,0);
- }
-
- /*
- * Function : Button on mouse down callback
- */
- func i32x CM2BmpButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_dtCM2BmpButton pdtButton;
-
- pthis = GetThis();
- pdtButton = GetData(pthis);
-
- // change button style
- if(!pdtButton.bChecked)
- SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
- else
- SetArea(GetSprite(pthis),pdtButton.iIndex);
- }
-
- /*
- * Function : Button Mouse click callback
- * Remarks : Test left click
- * Remarks : Push click message to parent
- * Message : "MouseClick"
- */
- func void CM2BmpButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
- var Gui_dtCM2BmpButton pdtButton;
-
- pthis = GetThis();
- parent = GetParent(pthis);
- pdtButton = GetData(pthis);
-
- // change button style
- if(pdtButton.bChecked)
- {
- SetArea(GetSprite(pthis),pdtButton.iIndex);
- pdtButton.bChecked=0;
- parent<<Uncheck(pthis);
- }
- else
- {
- SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
- pdtButton.bChecked=1;
- parent<<Click(pthis);
- }
- }
-
- /*
- * Function : Button check callback
- * Message : "Check"
- */
- func i32x CM2BmpButton_OnCheck(Gui_Component _pSender)
- {
- var Gui_Component pthis;
- var Gui_Component parent;
- var Gui_dtCM2BmpButton pdtButton;
-
- pthis = GetThis();
- parent = GetParent(pthis);
- pdtButton = GetData(pthis);
-
- // change button style
- if(!pdtButton.bChecked)
- {
- SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
- pdtButton.bChecked=1;
- parent<<Click(pthis);
- }
- return 1;
- }
-